﻿export default function define(Blocks: Blockly.BlockDefinitions) {

  Blocks['create_list'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("list"), "list")
          .appendField(" = [");
      this.appendValueInput("text")
          .setCheck(null);
      this.appendDummyInput()
          .appendField("]");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#15BAD4");
   this.setTooltip("创建列表");
   this.setHelpUrl("");
    }
  };
  
  Blocks['calllist'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("list"), "list");
      this.appendDummyInput()
      	  .appendField(" = list(");
      this.appendValueInput("value")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(")");	  
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#15BAD4");
   this.setTooltip("初始化列表");
   this.setHelpUrl("");
    }
  };

  Blocks['selectlist'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("list"), "list")
          .appendField("[");
      this.appendValueInput("NAME")
          .setCheck(null);
      this.appendDummyInput()
          .appendField("] = ");
      this.appendValueInput("value")
          .setCheck(null);  
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#15BAD4");
   this.setTooltip("列表赋值");
   this.setHelpUrl("");
    }
  };

  Blocks['selectlist2'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("list"), "list")
          .appendField("[");
      this.appendValueInput("NAME")
          .setCheck(null);
      this.appendDummyInput()
          .appendField("]");
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#15BAD4");
   this.setTooltip("列表中选择");
   this.setHelpUrl("");
    }
  };

  Blocks['optionlist'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("list"), "list")
          .appendField(".")
          .appendField(new Blockly.FieldDropdown([["添加(append)","append"], ["替代(replace)","replace"], ["插入(insert)","insert"], ["扩展(extend)","extend"], ["删除(pop)","pop"], ["删除(remove)","remove"]]), "options")
          .appendField("(");
      this.appendValueInput("text")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(")");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#15BAD4");
   this.setTooltip("对列表操作");
   this.setHelpUrl("");
    }
  };
  
  Blocks['optionlist2'] = {
    init: function() {
      this.appendDummyInput()
          .appendField(new Blockly.FieldVariable("list"), "list")
          .appendField(".")
          .appendField(new Blockly.FieldDropdown([["添加(append)","append"], ["替代(replace)","replace"], ["插入(insert)","insert"], ["扩展(extend)","extend"], ["删除(pop)","pop"], ["删除(remove)","remove"]]), "options")
          .appendField("(");
      this.appendValueInput("text")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(")");
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#15BAD4");
   this.setTooltip("对列表操作");
   this.setHelpUrl("");
    }
  };
}

